<template>
  <router-view />
  <van-tabbar route>
    <van-tabbar-item to="/home" icon="home-o">home</van-tabbar-item>
    <van-tabbar-item to="/car" icon="cart-o">car</van-tabbar-item>
    <van-tabbar-item to="/login" icon="manager-o" v-if="!token">login</van-tabbar-item>
    <van-tabbar-item to="/user" icon="manager-o" v-else>user</van-tabbar-item>
  </van-tabbar>
</template>

<script setup lang="ts">
import { ref, onMounted } from "vue";
import type { Ref } from "vue"
import { useUserInfoStore } from "@/stores/userInfo"

const token: Ref<string> = ref("");
const store = useUserInfoStore();

onMounted(() => {
  if (!token.value && localStorage.getItem("userToken")) {
    store.userToken = localStorage.getItem("userToken") as string;
    token.value = store.getUserToken;
  }
})
</script>

<style>

</style>
